home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / memdump / memdump.h < prev    next >
Text File  |  1994-11-16  |  4KB  |  224 lines

  1. ;;******************************************************************
  2. ;;使用例:    memdump    es,[20h]
  3. memdump    macro    _sreg,_oadr
  4.     push    ebx
  5.  
  6.     lea    ebx,_oadr
  7.     mov    ebp,_sreg    ;;sregにebxと渡すのは駄目
  8.     call    _proc_memdump
  9.     
  10.     pop    ebx
  11.     endm
  12.     align    4
  13. _proc_memdump    proc
  14.         push    es
  15.         push    eax
  16.         push    ecx
  17.         push    edx
  18.         push    esi
  19.         mov    es,ebp        ;;es:ebxの16アラインを読み込む
  20.     
  21.         nummsg    freework[20],ebp    ;;es=eax
  22.         mov    byte ptr freework[28],":"    ;;$の代わりに
  23.         nummsg    freework[29],ebx    ;;offset
  24.         cutzero    freework[20]
  25.  
  26.         lea    edx,byte ptr [freework+20]
  27.         mov    ah,9h
  28.         int    21h
  29.  
  30.         lea    edx,#green
  31.         mov    ah,9h
  32.         int    21h
  33.         
  34.         mov    ecx,16
  35.         mov    dword ptr freework[56],"    "
  36.         xor    esi,esi
  37.         xor    ebp,ebp
  38.     #l1:
  39.         mov    al,es:[ebx+esi]
  40.                 ;;そのままの表示(右端)
  41.                 cmp    al,20h
  42.                 jae    short #canview
  43.             #cannotview:
  44.                 mov    byte ptr freework[60+esi],"."
  45.                 jmp    short #viewterm
  46.             #canview:
  47.                 mov    freework[60+esi],al
  48.             #viewterm:
  49.                 
  50.                 ;;--bit setup
  51.                     mov    ah,al
  52.                     and    ax,0000111111110000b 
  53.                     shr    al,4
  54.                 #_high_bit_processing:
  55.                     cmp    ah,0ah
  56.                     jb    short #_h_underten
  57.                     add    ah,37h
  58.                     jmp    short #_low_bit_processing
  59.                 #_h_underten:
  60.                     add    ah,30h
  61.                 
  62.                 #_low_bit_processing:
  63.                     cmp    al,0ah
  64.                     jb    short #_l_underten
  65.                     add    al,37h
  66.                     jmp    short #_processend
  67.                 #_l_underten:
  68.                     add    al,30h
  69.                 
  70.                 #_processend:
  71.                     mov word ptr freework[40],ax
  72.                     mov byte ptr freework[40+2],"$"
  73.         cmp    ebp,4
  74.         je    short #putbar
  75.         mov    ah,2h
  76.         mov    dl," "
  77.         int    21h
  78.     #asciiprint:
  79.         lea    edx,freework[40]
  80.         mov    ah,9h
  81.         int    21h
  82.         inc    esi
  83.         inc    ebp
  84.         loop    #l1
  85.         
  86.         lea    edx,#white
  87.         mov    ah,9h
  88.         int    21h
  89.         
  90.         mov    ah,40h        ;;初めの8文字+1
  91.         mov    bx,1
  92.         mov    ecx,9
  93.         lea    edx,freework[59]
  94.         int    21h
  95.  
  96.         mov    ah,9
  97.         lea    edx,#bar
  98.         int    21h
  99.         lea    edx,#white
  100.         int    21h
  101.         
  102.         add    ecx,2
  103.         mov    word ptr freework[76],0a0dh
  104.         mov    ah,40h
  105.         lea    edx,freework[68]
  106.         int    21h
  107.         ;;ダンプの数値[39]は毎回表示。文字本体[59]-[69]は一気に表示
  108.         pop    esi
  109.         pop    edx
  110.         pop    ecx
  111.         pop    eax
  112.         pop    es
  113.         ret
  114.     #putbar:
  115.             lea    edx,#bar
  116.             mov    ah,9h
  117.             int    21h
  118.             mov    ebp,0
  119.             jmp    short    #asciiprint
  120.  
  121.     #white    db    1bh,"[37m$"
  122.     #green    db    1bh,"[32m$"
  123.     #bar    db    1bh,"[1;7;31m"," ",1bh,"[0;32m$"
  124. _proc_memdump    endp    
  125.  
  126. nummsg    macro    para2,para1    ;;para1=32bit数(4byte) para2=文字格納adr
  127.             ;; =(32bit)=4byte=0.ff.ff.ff.ff.h
  128.             ;;よって文字は8+$で 9byte確保必要
  129.     pushad
  130.         ;;完璧なパラメータ受渡しをしている。
  131.         mov    dword ptr freework,eax    ;;eaxの初期状況保存
  132.     
  133.         mov    eax,para1        ;;eaxが破壊
  134.         push    eax
  135.  
  136.         mov    eax,dword ptr freework    ;;再状況設定
  137.         lea    ebx,para2
  138.         
  139.         pop    eax                        ;;受取済をロード
  140.     call    _proc_nummsg
  141.     popad
  142. endm
  143.  
  144. cutzero    macro    para2        ;;"0"を0にする
  145.     push    ebx
  146.         lea    ebx,para2
  147.         call    _proc_cutzero
  148.     pop        ebx
  149.     endm
  150.     align    4
  151. _proc_cutzero    proc
  152.     #cnvzero1:
  153.         cmp    byte ptr [ebx],"0"
  154.         je    #cnvzero2
  155.     
  156.         jmp    short #macroexit2
  157.     
  158.     #cnvzero2:        ;;置き換え
  159.         mov    byte ptr [ebx],0
  160.         inc    ebx
  161.         jmp    short #cnvzero1
  162.     
  163.     #macroexit2:
  164.         cmp    byte ptr [ebx],"$"
  165.         jne    #cnvzero3
  166.         mov    byte ptr [ebx-1],"0"
  167.     #cnvzero3:
  168.     ret
  169. _proc_cutzero    endp
  170.  
  171. ;;*******************************************************************
  172.         align    4
  173. _proc_nummsg    proc                ;;ebx=格納先アドレス eax=数値
  174.         push    ecx
  175.         push    edx
  176.         push    esi
  177.     
  178.             mov    esi,10000000h    ;;esiで割る
  179.             mov    ecx,8
  180.         align    4
  181.     #dword1:
  182.         push    ecx
  183.         
  184.         mov    edx,0
  185.         div    esi        ;;eax/diver(=esi)
  186.         
  187.         add    eax,30h
  188.         cmp    al,3ah
  189.         jb    short #under_ten
  190.         add    eax,7
  191.     #under_ten:
  192.         mov    byte ptr [ebx],al    ;;商の文字を転写
  193.             
  194.         
  195.         shr    esi,4    ;;HEX一つ右にずらす
  196.             
  197.         inc    ebx        ;;商の文字の格納先を一つずらす。
  198.     
  199.         mov    eax,edx        ;;余りを転写
  200.         
  201.         pop    ecx
  202.         loop    #dword1
  203.     
  204.         mov    byte ptr [ebx],"$"
  205.     pop    esi
  206.     pop    edx
  207.     pop    ecx
  208.     ret
  209. _proc_nummsg    endp
  210.  
  211. ;;*******************************************************************
  212.  
  213. FREEWORK    db    128 dup(0)
  214.  
  215. ;;*******************************************************************
  216. ;;ファイル先頭にあるように、
  217. ;;    ES,[ESI]
  218. ;;などとして使って下さい。[]を忘れないように。
  219. ;;尚、セグメントレジスタにeaxなどと言う指定もできない訳ではないですが、
  220. ;;                       ebxを使うのはお避け下さい。確実に失敗します。
  221. ;;あと、FREEWORKについては、ローカル#FREEWORKにした方がいいかも知れません
  222. ;;当然の事ですが、DSはFREEWORKを含むセグメントにしてくださいね
  223. ;;              (DSを変更したままにする人はあまり無いと思うけど)
  224.